package ${package.To};

import abc.model.IEntity;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
<#if hasAssociative?? && hasAssociative>
import abc.annotation.Associative;
import java.util.List;
</#if>
<#list table.importPackages as pkg>
import ${pkg};
</#list>
import org.springframework.stereotype.Component;
<#if swagger>
import io.swagger.v3.oas.annotations.media.Schema;

</#if>
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
<#if entityLombokModel>
    <#if chainModel>
import lombok.experimental.Accessors;
    </#if>
</#if>

/**
* <p>
    * ${table.comment!}
    * </p>
*
* @author ${author}
*/
<#if entityLombokModel>
@Data
    <#if chainModel>
@Accessors(chain = false)
    </#if>
</#if>
@Component
@ColumnWidth(15) // 表头行宽
@HeadRowHeight(20) // 表头行高
<#if swagger>
@Schema(name = "${to}", description = "${table.comment}")
</#if>
<#if superToClass??>
public class ${to} extends ${superToClass}<${to}> implements IEntity<${to}> {
<#else>
public class ${to} extends BaseEntity<${to}> implements IEntity<${to}> {
</#if>

<#-- ----------  BEGIN 字段循环遍历  ---------->
<#list table.fields as field>
    <#if field.keyFlag==1 >
        <#assign keyPropertyName="${field.propertyName}"/>
    </#if>

    <#if field.comment!?length gt 0>
        <#if swagger>
    /**
    * ${field.comment}
    */
    @Schema(name = "${field.propertyName}", description = "${field.comment}")
        <#else>
    /**
    * ${field.comment}
    */
        </#if>
    </#if>
    <#if field.keyFlag==1 >
    @ExcelIgnore
    <#-- 主键 -->
        <#if field.keyIdentityFlag>
    @TableId(value = "${field.annotationColumnName}", type = IdType.AUTO)
        <#elseif idType??>
    @TableId(value = "${field.annotationColumnName}", type = IdType.${idType})
        <#elseif field.convert>
    @TableId("${field.annotationColumnName}")
        </#if>
    <#-- 普通字段 -->
    <#elseif field.fill??>
    @ExcelIgnore
    <#-- -----   存在字段填充设置   ----->
        <#if field.convert>
    @TableField(value = "${field.annotationColumnName}", fill = FieldFill.${field.fill})
        <#else>
    @TableField(fill = FieldFill.${field.fill})
        </#if>
    <#elseif field.convert>
        <#if field.associative??>
    @ExcelIgnore
    @TableField(exist = false)
    ${field.associative}
        <#else>
    @TableField("${field.annotationColumnName}")
        </#if>
    <#else>
        <#if field.associative??>
    @ExcelIgnore
    @TableField(exist = false)
    ${field.associative}
        <#else>
    @TableField
        </#if>
    </#if>
    <#if field.propertyType="Long">
    @JsonSerialize(using = ToStringSerializer.class)
    </#if>
    <#if field.propertyType="Date">
    @DateTimeFormat
        <#if field.comment??>
    @ExcelProperty(value = "${field.comment}")
        </#if>
    <#else>
        <#if field.comment??>
    @ExcelProperty(value = "${field.comment}")
        </#if>
    </#if>
    private ${field.propertyType} ${field.propertyName};
</#list>
<#------------  END 字段循环遍历  ---------->
<#if !entityLombokModel>
    <#list table.fields as field>
        <#if field.propertyType == "boolean" || field.propertyType == "Boolean">
            <#assign getprefix="is"/>
        <#else>
            <#assign getprefix="get"/>
        </#if>

    public ${field.propertyType} ${getprefix}${field.capitalName}() {
        return ${field.propertyName};
    }

        <#if chainModel>
    public ${to} set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        <#else>
    public void set${field.capitalName}(${field.propertyType} ${field.propertyName}) {
        </#if>
        this.${field.propertyName} = ${field.propertyName};
        <#if chainModel>
            return this;
        </#if>
    }
    </#list>
</#if>

<#if !entityLombokModel>

    @Override
    public String toString() {
    return "${to}{" +
    <#list table.fields as field>
        <#if field_index==0>
            "${field.propertyName} = " + ${field.propertyName} +
        <#else>
            ", ${field.propertyName} = " + ${field.propertyName} +
        </#if>
    </#list>
    "}";
    }
</#if>
}
